﻿using System;
using System.Data;
using System.Text;
using ZHDJ.Core;
using ZHDJ.Data.Models.Common;
using ZHDJ.WebPage.Master;

namespace ZHDJ.Web.Portal.Edu
{
    public partial class PartyEduHonourMore : UseMorePageMasterPage
    {
        /// <summary>
        /// 页数
        /// </summary>
        private string PageIndex
        {
            get
            {
                return this.Request["PageIndex"] ?? "";
            }
        }

        /// <summary>
        /// 每页条数
        /// </summary>
        private string PageSize
        {
            get
            {
                return this.Request["PageSize"] ?? "";
            }
        }

        private string BranchID
        {
            get
            {
                return this.Request["BranchID"] ?? "";
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }

            if (!string.IsNullOrEmpty(this.PageIndex))
            {
                this.WriteList();
            }
            else
            {
                this.hfCategory.Value = this.Category;
                this.hfTotalCount.Value = PartyArticle.GetMoreArticleTitle(0, 1, this.BranchID, SysDataDictionary.EduHonour, this.Category, false).Tables[1].Rows[0][0].ToString();
            }
        }
        public void LoadData()
        {

        }

        private void WriteList()
        {
            StringBuilder sbHtml = new StringBuilder();
            int startIndex = (Convert.ToInt32(this.PageIndex) - 1) * Convert.ToInt32(this.PageSize);
            DataTable dt = PartyArticle.GetMoreArticleTitle(Convert.ToInt32(PageSize), startIndex, this.BranchID, SysDataDictionary.EduHonour, this.Category, false).Tables[0];

            foreach (DataRow item in dt.Rows)
            {
                sbHtml.Append("<li>");
                sbHtml.Append("<span>" + Convert.ToDateTime(item["CreateTime"]).ToString("yyyy-MM-dd HH:mm") + "</span>");
                sbHtml.Append("<a href=\"PartyEduHonourDetail.aspx?id=" + Convert.ToString(item["ID"]) + "\" >" + Convert.ToString(item["Title"]) + "</a>");
                sbHtml.Append("</li>");
            }

            Response.Clear();
            Response.Write(sbHtml.ToString());
            Response.End();
        }

        #region 模块菜单
        /// <summary>
        /// 初始化module  如果通过url传参可不设置
        /// </summary>
        protected override void InitModule()
        {
            Module = "Honour";
            //Category = "";

        }
        #endregion
    }
}